<template>
  <view class="home">
    <view class="home-tab">
      <view class="tab-title">
        <uni-segmented-control 
        :current="current" 
        :values="items.map(v=>v.title)" 
        @clickItem="onClickItem" 
        styleType="text" 
        activeColor="#d4237a">
        </uni-segmented-control>
      </view>
    <view class="content">
        <view v-if="current === 0">
          <recommend></recommend>
        </view>
        <view v-if="current === 1">
          <category></category>
        </view>
        <view v-if="current === 2">
          <homenew></homenew>
        </view>
        <view v-if="current ===3">
          <album></album>
        </view>
    </view>
    </view>
  </view>
</template>

<script>
  import {uniSegmentedControl} from '@dcloudio/uni-ui';
  import recommend from './home-recommend/index.vue';
  import homenew from './home-new/index.vue';
  import category from './home-category';
  import album from './home-album';
export default {
  name: 'home',
  data() { 
    return {
      items:[
        {title:"推荐"},
        {title:'分类'},
        {title:'最新'},
        {title:'专题'}],
      current:0
    }
  },
  methods:{
    onClickItem(e){
      if(this.current !==e.currentIndex){
        // console.log(e.currentIndex);
        this.current =e.currentIndex
      }
    },
    onload(){
      this.requst({
        url:"http://157.122.54.189:9088/image/v3/homepage/vertical"
      }).then(res=>{
        console.log(res);
      })
    }
  },
  components:{
    uniSegmentedControl,
    recommend,
    album,
    homenew,
    category
  },
  onload(){
    uni.requst({
      
    })
  }
 }
</script>

<style lang="" scoped>
</style>